package com.reebake.ideal.storage.controller;

import java.util.List;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.reebake.ideal.mybatis.core.PageResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.reebake.ideal.storage.entity.FilePartDetail;
import com.reebake.ideal.storage.service.FilePartDetailService;
import com.reebake.ideal.storage.vo.FilePartDetailQueryParamVO;
import com.reebake.ideal.storage.vo.FilePartDetailVO;

 /**
 * 文件分片信息控制层
 */
@Tag(name = "文件分片信息对象功能接口")
@RestController
@RequestMapping("/file/part/detail")
public class FilePartDetailController {
    @Autowired
    private FilePartDetailService filePartDetailService;
    
    /** 
     * 分页查询
     *
     * @param queryParam 查询参数
     * @return 查询结果
     */
    @Operation(summary = "分页查询")
    @PostMapping("page")
    public PageResult<FilePartDetailVO> page(@RequestBody FilePartDetailQueryParamVO queryParam) {
        LambdaQueryWrapper<FilePartDetail> queryWrapper = new LambdaQueryWrapper<>();
        
        queryParam = filePartDetailService.page(queryParam, queryWrapper);
        
        return queryParam.to(FilePartDetailVO.class);
    }
    
    /** 
     * 保存或更新数据
     *
     * @param filePartDetail 实例对象
     */
    @Operation(summary = "保存或更新数据")
    @PostMapping("save")
    public void save(@RequestBody FilePartDetailVO filePartDetail) {
        filePartDetailService.saveOrUpdate(BeanUtil.copyProperties(filePartDetail, FilePartDetail.class));
    }
    
    /** 
     * 通过主键批量删除
     *
     * @param filePartDetailIds 主键
     */
    @Operation(summary = "通过主键批量删除")
    @PostMapping("remove-by-ids")
    public void removeByIds(@RequestBody List<String> filePartDetailIds) {
        filePartDetailService.removeByIds(filePartDetailIds);
    }
}